import { defineStore } from "pinia";
import { ref,reactive } from "vue";
export const useUserStore = defineStore("user",()=>{
    // 登录token
    const accessToken = ref('');
    // 修改access_token
    function setAccessToken(access_token){
        accessToken.value = access_token;
    }
    // 用户登录信息
    const userInfo = reactive({});
    // 修改用户信息
    function setUserInfo(user_info){
        Object.assign(userInfo,user_info);
    }
    return {
        accessToken,
        userInfo,
        setAccessToken,
        setUserInfo
    }
},{
    persist:[
        {
            key:'token',
            paths:['accessToken'],
            storage: sessionStorage,
        }
    ],
});